import re

# 定义中文标点符号
chinese_punctuation = r'[，。：、；“”‘’（）【】《》——……·！？]'

# 读取红楼梦.txt文件
with open('红楼梦.txt', 'r', encoding='utf-8') as f:
    content = f.read()

# 将中文标点符号替换为空格
processed_content = re.sub(chinese_punctuation, ' ', content)

# 写入temp.txt文件
with open('temp.txt', 'w', encoding='utf-8') as f:
    f.write(processed_content)

print("处理完成，已将中文标点符号替换为空格并保存为temp.txt")